package org.big.rocktproducer.medium;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(
        topic = "order-topic",
        consumerGroup = "order-consumer-group"
)
public class OrderConsumerMedium implements RocketMQListener<Order> {

    @Override
    public void onMessage(Order order) {
        System.out.println("Received order: " + order);

        // 根据订单状态处理业务逻辑
        if ("PAID".equals(order.getStatus())) {
            System.out.println("Processing payment for order: " + order.getOrderId());
        } else if ("CANCELLED".equals(order.getStatus())) {
            System.out.println("Handling cancellation for order: " + order.getOrderId());
        }
    }
}